package com.muhuahealth.service.impl;

import com.muhuahealth.dao.RoadRepairDao;
import com.muhuahealth.entity.RoadRepairEntity;
import com.muhuahealth.service.RoadRepairService;
import com.muhuahealth.utils.PageQueryUtil;
import com.muhuahealth.utils.PageResult;
import com.muhuahealth.utils.ServerResponse;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author GSK
 * @version 1.0
 * @date 2021/1/24 18:16
 */
@Log4j2
@Service
public class RoadRepairServiceImpl implements RoadRepairService {

    @Autowired
    RoadRepairDao roadRepairDao;

    @Override
    public PageResult getRoadRepairListPage(PageQueryUtil queryUtil) {

        List<RoadRepairEntity> entityList = roadRepairDao.findRoadRepairListPage(queryUtil);
        int totalPage = roadRepairDao.getTotalPage(queryUtil);
        PageResult pageResult = new PageResult(entityList,totalPage,queryUtil.getLimit(),queryUtil.getPage());
        return pageResult;
    }

    @Override
    public List<RoadRepairEntity> getSearchResult(RoadRepairEntity repairEntity) {

        log.info("开始查询");
        List<RoadRepairEntity> list = roadRepairDao.getSearchResult(repairEntity);

        return list;
    }

    @Override
    public String addNewRoadData(RoadRepairEntity repairEntity) {
        Integer count = roadRepairDao.addNewRoadData(repairEntity);
        log.info("添加===>" + count);
        if(count > 0){
            return "添加成功";
        }
        return "添加失败！";
    }
}
